<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>测试页面</h1>
  
  <script>
function testSometing() {
    console.log("执行testSometing");
    return "testSometing";
}

async function testAsync() {
    console.log("执行testAsync");
    return Promise.resolve("hello async");
}

async function test() {

    console.log("test start...");
    const v1 = await testSometing();//关键点1
    if(){}
    console.log(v1);
    const v2 = await testAsync();
    console.log(v2);
    console.log(v1, v2);
    console.log("test end...")
}

test();

var promise = new Promise((resolve)=> {
  console.log("promise start..");
  resolve("promise");
  });//关键点2
promise.then((val)=> console.log(val));

console.log("test end...")

/*
test start...
test.html:14 执行testSometing
test.html:35 promise start..
test.html:40 test end...
test.html:26 testSometing
test.html:19 执行testAsync
test.html:38 promise
test.html:28 hello async
test.html:29 testSometing hello async
test.html:70 Live reload enabled.
*/


/*
test start...
test.html:14 执行testSometing
test.html:41 test end...
test.html:26 testSometing
test.html:19 执行testAsync
test.html:28 hello async
test.html:29 testSometing hello async
test.html:30 test end...
*/ 
  </script>
</body>
</html>